#!/usr/bin/perl -w
#===============================================================================
#
#         FILE:  File_Generation_Time_Check_phased.pl
#
#        USAGE:  File_Generation_Time_Check_phased.pl
#
#  DESCRIPTION:  
#
#      OPTIONS:  ---
# REQUIREMENTS:  ---
#         BUGS:  ---
#        NOTES:  ---
#       AUTHOR:  ZHOU LEI , <networklei@gmail.com>
#      COMPANY:  ultrapower
#      VERSION:  1.0
#      CREATED:  09/15/2009 22:00:17 PM CST
#     REVISION:  ---
#===============================================================================
use Time::Local;

$DIR = "/home/lester/Perl/Test";

chdir $DIR;

@list=`ls -lrt`;

$_ = pop(@list);

@file = split(" ",$_);

$file_name = pop(@file);

$file_time = (stat $file_name)[9];

print "File Time :$file_time\n"; 

chomp($time = `date '+%H:%M'`);

chomp($_ = `date '+%Y%m%d%H%M%S'`);

/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ or die "Not a date";

$local_time = timelocal($6,$5,$4,$3,$2 - 1,$1);

print "Local Time : $local_time\n";

$time_difference = $local_time - $file_time;

print "Time Difference : $time_difference\n";

#print "$time\n";

if ($time =~ /(((0[89])|(1[0-9])|(2[012])):[1-5][0-9])/){
	#print "$1\n";
	if ( $time_difference < 3600 ){
		 print "File creation time is less than 3600, File Generation Check ok\n";
	}else{
		print "File creation time is greater than 3600, File Generation timeOut\n";
	}
}elsif ($time =~ /(((23)|(0[0-7])|(2[012])):[1-5][0-9])/){
		
	if ( $time_difference  < 21600){
		 print "File creation time is less than 21600, File Generation Check ok\n";
	}else{
		print "File creation time is greater than 21600, File Generation timeOut\n";
	}
}
print "123"
